
<template>
  <div>
    <Modal
      v-model="showBox"
      :title="(companyAll.is_bind_blank?'修改':'绑定')+'银行卡'"
      :footer-hide="true"
      :mask-closable="false"
      @on-visible-change="vChange"
      width="500"
    >
      <Input type="text" v-model="blank_username" placeholder="请输入姓名" ref="blank_username" class="marginB20" size="large" clearable>
        <Icon type="ios-contact" slot="prefix" />
      </Input>
      <Input type="text" v-model="blank_name" placeholder="请输入银行名称" ref="blank_name" class="marginB20" size="large" clearable>
        <Icon type="ios-home" slot="prefix" />
      </Input>
      <Input type="number" v-model="blank_account" placeholder="请输入正确的卡号" ref="blank_account" class="marginB20" size="large" clearable
      onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"
      >
        <Icon type="ios-card" slot="prefix" />
      </Input>
      <Input type="text" v-model="blank_type" placeholder="请输入户行" ref="blank_type" class="marginB20" size="large" clearable>
        <Icon type="ios-home-outline" slot="prefix" />
      </Input>
      
      

      <Button type="primary" class="marginB10" size="large" long @click="goFun">确 定</Button>
    </Modal>
  </div>
</template>



<script>
export default {
  name: "bankCardSet",
  components: {},
  data() {
    return {
      // 弹框是否显示
      showBox: false,
      companyAll:'',
      blank_name:'',
      blank_type:'',
      blank_account:'',
      blank_username:''

    };
  },
  created(){ },
  mounted() {},
  methods: {
    //提交
    goFun() {
      let that=this;
      let {
        blank_name,
        blank_type,
        blank_account,
        blank_username
      }=that;
      if(!$app.judgeData($app.delSpace(blank_name))){
        that.$Message.error({content:'开户行名称不能为空'});
        that.$refs['blank_name'].focus();
      }else if(!$app.judgeData($app.delSpace(blank_type))){
        that.$Message.error({content:'开户行分行名称不能为空'});
        that.$refs['blank_type'].focus();
      }else if(!$app.bankcardCheck(blank_account)){
        that.$Message.error({content:'请输入正确的银行卡格式，勿含空格等特殊字符'});
        that.$refs['blank_account'].focus();
      }else if(!$app.judgeData($app.delSpace(blank_username))){
        that.$Message.error({content:'开户人姓名不能为空'});
        that.$refs['blank_username'].focus();
      }else{
        $ajax.bindBlankXx(blank_name,blank_type,blank_account,blank_username,that,()=>{
          this.$parent.$emit('up_cAll');// 更新 companyAll数据
          that.showBox=false;
        });
      }
    },

    //弹框消失
    vChange(buEr) {
      if(!buEr){
        
        
        
      }else{
        $ajax.pInfo(resData => {
          this.companyAll=resData;
          let {
            blank_name,
            blank_type,
            blank_account,
            blank_username
          }=resData;
          this.blank_name=blank_name;
          this.blank_type=blank_type;
          this.blank_account=blank_account;
          this.blank_username=blank_username;
        });
      }
    }
  }
};
</script>

<style>
</style>
